﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QL_Nha_Sach_Phuong_Nam
{
    public partial class Formchonphieudat : Form
    {
        //Khai bao bien nha cung cap
        NhaCungCap ncc;

        private PhieuDat pd;

        public PhieuDat Pd
        {
            get { return pd; }
        }


        //Khai bao CxulyPhieuDat va CXulySach
        CXulythongtinsach xulysach;
        CXulyPhieuDat xulyPhieuDat;


        public Formchonphieudat(NhaCungCap n)
        {
            InitializeComponent();
            ncc = n;
        }

        private void btnchon_Click(object sender, EventArgs e)
        {
            foreach(ListViewItem lvi in lstchonphieudat.SelectedItems)
            {
                pd = xulyPhieuDat.TimPhieudat(lvi.SubItems[0].Text);
            }
            Close();
        }

        private void Formchonphieudat_Load(object sender, EventArgs e)
        {
            xulysach = new CXulythongtinsach();
            xulyPhieuDat = new CXulyPhieuDat();

            //new phieu dat
            pd = null;

            //Hien danh sach phieu dat cua nha cung cap
            foreach (PhieuDat p in ncc.PhieuDats)
            {
                if(p.PhieuDatStatus=="live" && p.PhieuDatComplete=="no")
                {
                    ListViewItem lvi = lstchonphieudat.Items.Add(p.PhieuDatNo);
                    lvi.SubItems.Add(p.PhieuDatDeliveTime.ToString());
                    lvi.SubItems.Add(ncc.NhaCungCapName);
                }
            }
        }
    }
}
